home *** CD-ROM | disk | FTP | other *** search
- Well, I was bored, so I cooked up the bare bones for a text adventure
- game. It may not look pretty, but what's here works so far. Here's a
- breakdown of the variables and procedures...
-
- NW Number of words per command (max).
- W$() Holds command and its parameters. W$(1) is the command,
- and W$(2) is its first parameter. A "###" in an element
- means that there are no more parameters to follow.
- RD$() Holds room descriptions.
- OB$() Holds object descriptions. OB$(x,0) is the object's name,
- OB$(x,1) is it's description for EXAMINE[], and OB$(x,2) is
- reserved for future expansion.
- OB() Holds object information. OB(x,0) is the room that the object
- is in. A 0 indicates that the player is holding the object. The
- other elements are unused, but are for things like score, weight,
- and special attributes.
- RM() Holds room information. RM(x,0) contains the number of objects in
- a room. RM(x,1) to RM(x,10) indicate which rooms are accessible
- in which direction. (See D$())
- D$() Directions corresponiding to RM(x,1) - RM(x,10).
- DD$() Abbreviations of directions for moving.
- CD$ Moves the cursor to the left of the screen and down one line for
- formatting data strings.
-
- BRKSENTENCE[] Breaks A$ down into words and stores them in W$().
- SROOM[] Displays current room, showing exits and objects.
- CMD[] Displays a prompt and reads a command. If a null is entered
- a "Huh?" is displayed, and if the word "again" is entered, it
- repeats the last command (passed as a parameter). The command
- is returned in Param$.
- TAKE Picks up objects and stores in player's inventory. Objects can be
- specified as "all" (picks up all objects in current room) or as a
- list (with "and" and "the" being ignored).
- DROP The antithesis to TAKE.
- INV Displays the player's inventory.
- EXAMINE Allows the player to examine an object if they are holding
- it. If the object is not held by the player but is in the room,
- a message will be displayed telling them to pick it up. If the
- object isn't in the room, it tells you there isn't one.
- HELP Hah!
- TME Displays the game time. Each turn takes a "minute" excluding
- invalid commands.
- DUMP A debugging aid - displays the contents of W$().
-
- Current commands:
-
- n, s, e, w, ne, se, nw, sw, up, down : Move in the desired direction.
- get, take : Pick up objects.
- time : Show game time.
- help : Display a sarcastic message.
- drop : Drop objects.
- quit : Exit game.
- again : Repeat last command.
- look : Show room description, exits, and objects.
- inv, inventory : Show objects held by player.
- exam, examine : Look closely at an object.
-
- I'm working on containers (objects which can contain other objects), and
- functions for helping plot development, like DOES_HOLD, HAS_HELD,
- HAS_BEEN_TO, IS_IN, etc., plus things like automapping, et al. I also
- may turn it into an adventure creator, but that looks like hard work. :)
- (I'm also working on a multi-player version for people running TCP/IP,
- but I'm not even going to ATTEMPT that in AMOS - that's a job for C! :)
- Anyone recommend a decent PD or shareware C compiler? I'm using an
- ancient version of DICE at the moment....
-
- Anyway, here it is - sorry for the length of my posting and rambling, but
- it's been a slow day at work. :)
-
- (Oh, and I had to post raw ASCII 'cause I'm on a (hack, cough) PC at the
- moment.)
-
- ********************************
- Set Buffer 100
-
- Screen Open 0,640,200,4,Hires
-
-
-
-
-
- NW=20
-
-
-
- Dim W$(NW)
-
- Global W$()
-
-
-
- Dim RD$(64),OB$(256,2),OB(256,10),RM(64,15),D$(10)
-
- Global RD$(),OB$(),OB(),RM(),D$(),NW,TM
-
- Dim DD$(10)
-
- NAMEO=0
-
- DESCO=1
-
- NUMOB=0
-
- CURRM=1
-
- OBRM=0
-
-
-
- For OO=0 To 256
-
- OB(OO,0)=-1
-
- Next
-
-
-
- Global NAMEO,DESCO,NUMOB,CURRM,CD$,OBRM
-
- CD$=Chr$(27)+"X"+Chr$(48)+Cdown$
-
-
-
- D$(1)="north"
-
- D$(2)="south"
-
- D$(3)="east"
-
- D$(4)="west"
-
- D$(5)="north-east"
-
- D$(6)="south-east"
-
- D$(7)="north-west"
-
- D$(8)="south-west"
-
- D$(8)="up"
-
- D$(9)="down"
-
- DD$(1)="n" : DD$(2)="s" : DD$(3)="e" : DD$(4)="w"
-
- DD$(5)="ne" : DD$(6)="se" : DD$(7)="nw" : DD$(8)="sw"
-
- DD$(9)="up" : DD$(10)="down"
-
- RD$(1)="Starting point"+CD$+CD$+"Not a lot to say about this room, really."
-
- RD$(1)=RD$(1)+CD$+"Pretty bare as far as these things go."
-
- RD$(2)="The other room"+CD$+CD$+"This room isn't much more exciting, I'm afraid."+CD$
-
- RD$(2)=RD$(2)+"You'll really have to wait until the game is finished."
-
- OB$(0,0)="knife"
-
- OB$(0,1)="A razor sharp kitchen knife."
-
- OB$(1,0)="egg"
-
- OB$(1,1)="A regular, common or garden, ordinary hen's egg."
-
- OB$(2,0)="box"
-
- OB$(2,1)="This box is too small to contain anything. (Actually I just haven't got"+CD$
-
- OB$(2,1)=OB$(2,1)+"round to implementing that yet. :)"
-
- OB$(3,0)="sock"
-
- OB$(3,1)="Pheew! That STINKS!"
-
- OB(0,0)=1
-
- OB(1,0)=1
-
- OB(2,0)=1
-
- OB(3,0)=2
-
- RM(1,0)=3
-
- RM(1,1)=2
-
- RM(2,2)=1
-
- RM(2,0)=1
-
-
-
- Q$=""
-
- SROOM[CURRM]
-
- Do
-
- SUCC=False
-
- CMD[Q$]
-
- Q$=Param$
-
- BRKSENTENCE[Q$]
-
- CM$=W$(1)
-
- If CM$="look"
-
- Print
-
- SROOM[CURRM]
-
- SUCC=True
-
- End If
-
- If CM$="quit"
-
- Edit
-
- End If
-
- For QQ=1 To 10
-
- If CM$=DD$(QQ)
-
- SUCC=True
-
- If RM(CURRM,QQ)>0
-
- CURRM=RM(CURRM,QQ)
-
- Print
-
- SROOM[CURRM]
-
- Else
-
- Print "You can't go that way!"
-
- End If
-
- End If
-
- Next
-
- If CM$="time"
-
- SUCC=True
-
- TME
-
- End If
-
- If CM$="get" or CM$="take"
-
- SUCC=True
-
- TAKE
-
- End If
-
- If CM$="drop"
-
- SUCC=True
-
- DROP
-
- End If
-
- If CM$="inv" or CM$="inventory"
-
- SUCC=True
-
- INV
-
- End If
-
- If CM$="exam" or CM$="examine"
-
- SUCC=True
-
- EXAMINE
-
- End If
-
- If CM$="help"
-
- SUCC=True
-
- HELP
-
- End If
-
- If CM$="wait"
-
- SUCC=True
-
- Print "Time passes..."
-
- End If
-
-
-
- If Not SUCC
-
- Print "I don't know how to ";CM$;"."
-
- Else
-
- Inc TM
-
- End If
-
-
-
- Loop
-
-
-
- ' *** Procedures ***
-
-
-
- Procedure BRKSENTENCE[A$]
-
-
-
- T$=Lower$((A$-".")-",")
-
-
-
- For J=1 To NW
-
- If Instr(T$," ")=0
-
- If Not SW
-
- W$(J)=T$
-
- SW=True
-
- Else
-
- W$(J)="###"
-
- End If
-
- Else
-
- If Not SW
-
- I=Instr(T$," ")
-
- W$(J)=Left$(T$,I-1)
-
- T$=Right$(T$,(Len(T$)-I))
-
- End If
-
- End If
-
- Next
-
-
-
- End Proc
-
- Procedure DUMP
-
-
-
- For J=1 To NW
-
- Print W$(J);" ";
-
- Next
-
-
-
- End Proc
-
- Procedure SROOM[N]
-
-
-
- Print RD$(N)
-
- Print
-
- If RM(CURRM,NUMOB)>0
-
- Print "You see";
-
- Q=RM(N,NUMOB)
-
- V=Q
-
- For R=0 To 256
-
- If OB(R,0)=N
-
- If Q<>V and Q>1
-
- Print ",";
-
- End If
-
- If Q>1
-
- Print " a";
-
- Else
-
- If Q<>V
-
- Print " and a";
-
- Else
-
- Print " a";
-
- End If
-
- End If
-
- Q=Q-1
-
- O$=OB$(R,NAMEO)
-
- If Instr("aeiouAEIOU",Left$(O$,1))<>0
-
- Print "n ";
-
- Else
-
- Print " ";
-
- End If
-
- Print O$;
-
- End If
-
- Next
-
- Print "."
-
- End If
-
-
-
- Print
-
- Print "Exits :";
-
- For Q=1 To 10
-
- If RM(N,Q)>0
-
- EX=True
-
- Print " ";D$(Q);
-
- End If
-
- Next Q
-
- If Not EX
-
- Print " None! Contact the author and quote error : $400";
-
- Print Str$(N)-" ";
-
- End If
-
- Print "."
-
-
-
- End Proc
-
- Procedure CMD[L$]
-
-
-
- C$=""
-
- While C$=""
-
- Print
-
- Input "> ";C$
-
- If C$=""
-
- Print "Huh?"
-
- End If
-
- Wend
-
- If Lower$(C$)="again"
-
- C$=L$
-
- End If
-
-
-
- End Proc[C$]
-
- Procedure TAKE
-
-
-
- If W$(2)="all"
-
-
-
- If RM(CURRM,NUMOB)>0
-
- FRST=True
-
- For OO=0 To 256
-
- If OB(OO,OBRM)=CURRM
-
- OB(OO,OBRM)=0
-
- If FRST
-
- Print Upper$(Left$(OB$(OO,0),1));
-
- Print Right$(OB$(OO,0),Len(OB$(OO,0))-1);
-
- FRST=False
-
- Else
-
- Print ", ";OB$(OO,0);
-
- End If
-
- End If
-
- Next
-
- RM(CURRM,NUMOB)=0
-
- Print " taken."
-
- Else
-
- Print "Nothing to take!"
-
- End If
-
-
-
- Else If W$(2)="###"
-
-
-
- Print "Take what?"
-
-
-
- Else
-
- FRST=True
-
- AFO=False
-
- For QQ=2 To NW
-
- CO$=W$(QQ)
-
- If CO$<>"###" and CO$<>"the" and CO$<>"and"
-
- FO=False
-
- For OO=0 To 256
-
- If OB$(OO,0)=CO$
-
- If OB(OO,OBRM)=CURRM
-
- OB(OO,OBRM)=0
-
- RM(CURRM,NUMOB)=RM(CURRM,NUMOB)-1
-
- FO=True
-
- AFO=True
-
- If FRST
-
- Print Upper$(Left$(CO$,1));
-
- Print Right$(CO$,Len(CO$)-1);
-
- FRST=False
-
- Else
-
- Print ", ";OB$(OO,0);
-
- End If
-
- End If
-
- End If
-
- Next
-
- If Not FO
-
- If AFO
-
- Print " taken, but you don't see any ";CO$"."
-
- Else
-
- Print "You don't see any ";CO$;"."
-
- End If
-
- FO=False
-
- AFO=False
-
- FRST=True
-
- End If
-
- End If
-
- Next
-
- If FO
-
- Print " taken."
-
- End If
-
- End If
-
- End Proc
-
- Procedure DROP
-
-
-
- FRST=True
-
- DR=False
-
- If W$(2)="all"
-
-
-
- For OO=0 To 256
-
- If OB(OO,OBRM)=0
-
- OB(OO,OBRM)=CURRM
-
- If FRST
-
- Print Upper$(Left$(OB$(OO,0),1));
-
- Print Right$(OB$(OO,0),Len(OB$(OO,0))-1);
-
- FRST=False
-
- Else
-
- Print ", ";OB$(OO,0);
-
- End If
-
- DR=True
-
- End If
-
- Next
-
- OC=0
-
- For OO=0 To 256
-
- If OB(OO,0)=CURRM
-
- Inc OC
-
- End If
-
- Next
-
- RM(CURRM,NUMOB)=OC
-
-
-
-
-
- If Not DR
-
- Print "Nothing to drop!"
-
- Else
-
- Print " dropped."
-
- End If
-
-
-
- Else If W$(2)="###"
-
-
-
- Print "Drop what?"
-
-
-
- Else
-
- FRST=True
-
- ADR=False
-
- For QQ=2 To NW
-
- CO$=W$(QQ)
-
- If CO$<>"###" and CO$<>"the" and CO$<>"and"
-
- DR=False
-
- For OO=0 To 256
-
- If OB$(OO,0)=CO$
-
- If OB(OO,OBRM)=0
-
- OB(OO,OBRM)=CURRM
-
- RM(CURRM,NUMOB)=RM(CURRM,NUMOB)+1
-
- DR=True
-
- ADR=True
-
- If FRST
-
- Print Upper$(Left$(OB$(OO,0),1));
-
- Print Right$(OB$(OO,0),Len(OB$(OO,0))-1);
-
- FRST=False
-
- Else
-
- Print ", ";OB$(OO,0);
-
- End If
-
-
-
- End If
-
- End If
-
- Next
-
- If Not DR
-
- If ADR
-
- Print " dropped, but don't have a ";CO$;"."
-
- Else
-
- Print "You don't have a ";CO$;"."
-
- End If
-
- DR=False
-
- ADR=False
-
- FRST=True
-
- End If
-
- End If
-
- Next
-
- If DR
-
- Print " dropped."
-
- End If
-
- End If
-
-
-
- End Proc
-
- Procedure INV
-
-
-
- CAR=False
-
- Print "You are carrying :"
-
- For OO=0 To 256
-
- If OB(OO,OBRM)=0
-
- Print " ";OB$(OO,0)
-
- CAR=True
-
- End If
-
- Next
-
- If Not CAR
-
- Print " nothing."
-
- End If
-
-
-
- End Proc
-
- Procedure EXAMINE
-
-
-
- If W$(2)="###"
-
-
-
- Print "Examine what?"
-
-
-
- Else
-
-
-
- For OO=0 To 256
-
-
-
- If OB$(OO,0)=W$(2)
-
-
-
- If OB(OO,OBRM)=CURRM
-
- Print "You'll need to pick it up first!"
-
- EX=True
-
- End If
-
-
-
- If OB(OO,OBRM)=0
-
- EX=True
-
- Print OB$(OO,1)
-
- End If
-
-
-
- End If
-
-
-
- Next
-
-
-
- If Not EX
-
- Print "No ";W$(2);" to examine!"
-
- End If
-
-
-
- End If
-
-
-
-
-
-
-
- End Proc
-
- Procedure HELP
-
-
-
- Print "Hah! You must be kidding! Work it out yourself."
-
-
-
- End Proc
-
- Procedure TME
-
-
-
- Print "It's";(TM div 60);":";
-
- QQQ$=Str$((TM Mod 60))-" "
-
- Print QQQ$;" since you started."
-
-
-
- End Proc
-
-
- --
- GCS -d+ H+ s++:- g+ p? !au a- w+++ !Productions 1995
- v* C+++ UB+++A++++ P++ L++ E+ N+++ http://satelnet.org/~mentat/
- K+ !W--- M-- V po- Y+ t++ 5+ jx G?
- R tv++ D- B--- e+ u** h f r++ !n y+ "No matter where you go, there you are."
-
-
-
-